<%= stylesheet_link_tag :all %>

<h1>Editing user</h1>

<% form_for(@user) do |f| %>
  <%= f.error_messages %>

  <p>
    <%= f.label :email %>
    <%= f.text_field :email %>
  </p>
  <p>
    <%= f.label :firstname %>
    <%= f.text_field :firstname %>
  </p>
  <p>
    <%= f.label :lastname %>
    <%= f.text_field :lastname %>
  </p>
  <% @fieldtypes.each do |field| %>
    <p>
    <%= label_tag("custom[#{field.name}]", field.name) %>
    <% temp = field.data_fields.find(:first, :conditions => {:user_id => @user.id}) %>
    <% if temp != nil %>
      <%= text_field_tag("custom[#{field.name}]", temp.value) %>
    <% else %>
      <%= text_field_tag("custom[#{field.name}]") %>
    <% end %>
    </p>
  <% end %>  
  <p>
    <%= f.submit 'Update' %>
  </p>
<% end %>

<%= link_to 'Show', @user %> |
<%= link_to 'Back', users_path %>
